<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>滴滴法律</title>
	<link rel="stylesheet" type="text/css" href="css/normalize.css">
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<!--[if lt IE 9]> 
		<script> src="js/html5shiv.min.js"></script> 
	<![endif]-->
</head>
<body>
	<div class="well well-sm">法律知识 / 法律知识</div>
	<form class="form-inline" method="post" action="knowledge/search" style="margin-top:10px;">
	  <div class="form-group">
	  	<label for="part">选择分类：</label>
	    <select class="form-control" name="lawknowId" id="part">
	    	<option value="0">全部</option>
	    	<c:forEach items="${knowledges}" var="knowledges">
		    	<option value="${knowledges.lawknowid}" <c:if test="${knowledges.lawknowid == lawknowId}">selected="selected"</c:if>>${knowledges.name}</option>
	    	</c:forEach>
	    </select>
	  </div>
	  <button type="submit" class="btn btn-info">查询</button>
	  <a href="knowledge/add" class="btn btn-success">添加文章</a>
	</form>
	<table class="table table-striped table-hover">
		<thead>
			<tr>
				<th>编号</th>
				<th>名称</th>
				<th>浏览量</th>
				<th>上传时间</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="details" items="${details}" varStatus="status">
			<tr>
				<td>${status.index + 1}</td>
				<td>${details.title}</td>
				<td>0</td>
				<td><fmt:formatDate value="${details.publishTime}" pattern="yyyy-MM-dd hh:mm:ss"/></td>
				<td>
					<!-- <input class="btn btn-warning btn-xs" type="button" value="修改">
					<input class="btn btn-info btn-xs" type="button" value="冻结"> -->
					<input class="btn btn-danger btn-xs" type="button" onclick="del((${details.knowledgeId}))" value="删除">
				</td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
</body>
<script type="text/javascript">
function del(knowledgeId){
	$.ajax({
       	 type: 'get',
   	     url: "knowledge/remove/" + knowledgeId,
   	     dataType:'json',    
   	     success: function (data){
   	     	alert(data.msg);
   	     	if (data.code == 200) {
   	     		location.reload();
   	     	}
   	     }
	  });
}
  
  </script>
</html>